package com.xiti.student.base.entity.enums;

import com.fasterxml.jackson.annotation.JsonValue;

/**
 * 短信验证码类型(10登录验证码/20注册验证码/30修改密码验证码)
 */
public enum MobileCodeTypeEnum {
    login(10, "sms_template_login"),
    register(20, "sms_template_register"),
    modify(30, "sms_template_modify");

    private int value;
    private String desc;

    MobileCodeTypeEnum(final int value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    // 普通方法
    public static String getDescByValue(int index) {
        for (MobileCodeTypeEnum c : MobileCodeTypeEnum.values()) {
            if (c.value == index) {
                return c.desc;
            }
        }
        return null;
    }

    public int getValue() {
        return this.value;
    }

    @JsonValue
    public String getDesc(){
        return this.desc;
    }
}
